package UserGift;


import UserGift.dao.GiftDao;
import UserGift.dao.UserDao;
import UserGift.model.Gift;
import UserGift.model.User;

import java.util.Date;

public class TestManager {
    private UserDao userDao;
    private GiftDao giftDao;

    public TestManager() {
        userDao = new UserDao();
        giftDao = new GiftDao();
    }

    public void saveUsers() {
        User user1 = new User(1, "vasya", new Date());
        userDao.save(user1);
        User user2 = new User(2, "semen", new Date());
        userDao.save(user2);
    }

    public void saveGifts() {
        Gift gift1 = new Gift(1, "podarok1", "pen", 10);
        giftDao.save(gift1);
        Gift gift2 = new Gift(2, "podarok2", "book", 15);
        giftDao.save(gift2);
    }

    public void givUserGift(int user_id, int gift_id) {
        User u1 = userDao.getById(user_id);
        Gift g1 = giftDao.getById(gift_id);
        u1.getSetGefts().add(g1);
        userDao.update(u1);


    }
}
